<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="./vue.js"> </script>
  <style>
    .red {
      background: red;
      width: 100px;
      height: 100px;
    }
    .blue {
      background: blue;
      width: 100px;
      height: 100px;
    }
  </style>
</head>
<body>
  <div id="app">
    <!-- <div class="red"> </div> -->
    <hr>
    <!-- <div v-bind:class="color"> </div> -->
    <!-- <div :class="color"> </div> -->
    <div :class="state?'red':'blue'"></div>
    <button @click="toggle">toggle</button>
  </div>

  <script>
    /*
    标签属性的值是字符串
    标签属性的值是变量或者是表达式 属性绑定  数据的值绑定data里的数据
    v-bind:属性名="变量或者表达式"
    :属性名 = "变量或者表达式"
    方法千万不能写箭头函数
    */ 
    new Vue({
      el: "#app", 
      data: {  
        state: false,   
        name: "韩梅梅",
        color: 'blue'
      },
      methods: {
        toggle() {
          console.log(this)
          this.state = !this.state
        }
      }
    })
  </script>
</body>
</html>